Global Gender Inequality Index

This notebook aims to visualize the difference in gender inequality between 2010 and 2019

library(sf)
## Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE
library(terra)
## terra 1.6.17
library(here)
## here() starts at /Users/james/Documents/ucl/CASA0005_GIS/Practical/GIS_Course
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6      ✔ purrr   0.3.4 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::extract() masks terra::extract()
## ✖ dplyr::filter()  masks stats::filter()
## ✖ dplyr::lag()     masks stats::lag()
library(janitor)
## 
## Attaching package: 'janitor'
## 
## The following object is masked from 'package:terra':
## 
##     crosstab
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout

Prepare data

df <- read_csv(here('hw4-global_gender_inequality','data','HDR21-22_Composite_indices_complete_time_series.csv'))
## Rows: 206 Columns: 1008
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr    (4): iso3, country, hdicode, region
## dbl (1004): hdi_rank_2021, hdi_1990, hdi_1991, hdi_1992, hdi_1993, hdi_1994,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(df,10)
## # A tibble: 10 × 1,008
##    iso3  country  hdicode region hdi_r…¹ hdi_1…² hdi_1…³ hdi_1…⁴ hdi_1…⁵ hdi_1…⁶
##    <chr> <chr>    <chr>   <chr>    <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
##  1 AFG   Afghani… Low     SA         180   0.273   0.279   0.287   0.297   0.292
##  2 AGO   Angola   Medium  SSA        148  NA      NA      NA      NA      NA    
##  3 ALB   Albania  High    ECA         67   0.647   0.629   0.614   0.617   0.624
##  4 AND   Andorra  Very H… <NA>        40  NA      NA      NA      NA      NA    
##  5 ARE   United … Very H… AS          26   0.728   0.739   0.742   0.748   0.755
##  6 ARG   Argenti… Very H… LAC         47   0.723   0.73    0.735   0.739   0.744
##  7 ARM   Armenia  High    ECA         85   0.656   0.649   0.618   0.616   0.62 
##  8 ATG   Antigua… High    LAC         71  NA      NA      NA      NA      NA    
##  9 AUS   Austral… Very H… <NA>         5   0.865   0.867   0.869   0.873   0.873
## 10 AUT   Austria  Very H… <NA>        25   0.825   0.829   0.835   0.84    0.845
## # … with 998 more variables: hdi_1995 <dbl>, hdi_1996 <dbl>, hdi_1997 <dbl>,
## #   hdi_1998 <dbl>, hdi_1999 <dbl>, hdi_2000 <dbl>, hdi_2001 <dbl>,
## #   hdi_2002 <dbl>, hdi_2003 <dbl>, hdi_2004 <dbl>, hdi_2005 <dbl>,
## #   hdi_2006 <dbl>, hdi_2007 <dbl>, hdi_2008 <dbl>, hdi_2009 <dbl>,
## #   hdi_2010 <dbl>, hdi_2011 <dbl>, hdi_2012 <dbl>, hdi_2013 <dbl>,
## #   hdi_2014 <dbl>, hdi_2015 <dbl>, hdi_2016 <dbl>, hdi_2017 <dbl>,
## #   hdi_2018 <dbl>, hdi_2019 <dbl>, hdi_2020 <dbl>, hdi_2021 <dbl>, …
world_boundary <- st_read(here('hw4-global_gender_inequality','data','World_Countries_(Generalized).geojson'))
## Reading layer `World_Countries__Generalized_' from data source 
##   `/Users/james/Documents/ucl/CASA0005_GIS/Practical/GIS_Course/hw4-global_gender_inequality/data/World_Countries_(Generalized).geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 251 features and 7 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -89 xmax: 180 ymax: 83.6236
## Geodetic CRS:  WGS 84
world_boundary <- world_boundary %>%
  clean_names()

select global gender inequality data

gii_df <- df %>% 
  select(iso3,country,gii_2010,gii_2019) %>%
  mutate(gii_diff = gii_2010 - gii_2019)
gii_df
## # A tibble: 206 × 5
##    iso3  country              gii_2010 gii_2019 gii_diff
##    <chr> <chr>                   <dbl>    <dbl>    <dbl>
##  1 AFG   Afghanistan             0.753    0.665   0.088 
##  2 AGO   Angola                  0.551    0.537   0.0140
##  3 ALB   Albania                 0.246    0.156   0.09  
##  4 AND   Andorra                NA       NA      NA     
##  5 ARE   United Arab Emirates    0.175    0.056   0.119 
##  6 ARG   Argentina               0.364    0.306   0.058 
##  7 ARM   Armenia                 0.346    0.239   0.107 
##  8 ATG   Antigua and Barbuda    NA       NA      NA     
##  9 AUS   Australia               0.136    0.08    0.056 
## 10 AUT   Austria                 0.111    0.054   0.057 
## # … with 196 more rows

join with spatial data

world_gii <- world_boundary %>%
  left_join(.,gii_df,by=c('country' = 'country')) %>%
  drop_na()
world_gii
## Simple feature collection with 152 features and 11 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -180 ymin: -55.90223 xmax: 180 ymax: 83.11387
## Geodetic CRS:  WGS 84
## First 10 features:
##    fid     country iso  countryaff aff_iso shape_length shape_area iso3
## 1    1 Afghanistan  AF Afghanistan      AF    50.803210  62.566714  AFG
## 2    2     Albania  AL     Albania      AL     9.625038   3.073540  ALB
## 3    3     Algeria  DZ     Algeria      DZ    70.540082 213.513461  DZA
## 4    6      Angola  AO      Angola      AO    58.873470 103.813059  AGO
## 5   10   Argentina  AR   Argentina      AR   138.751348 278.308965  ARG
## 6   11     Armenia  AM     Armenia      AM    12.161117   3.142291  ARM
## 7   13   Australia  AU   Australia      AU   252.165238 695.539924  AUS
## 8   14     Austria  AT     Austria      AT    22.067937  10.039441  AUT
## 9   15  Azerbaijan  AZ  Azerbaijan      AZ    28.575135  17.407142  AZE
## 10  17     Bahamas  BS     Bahamas      BS    25.487759   1.079050  BHS
##    gii_2010 gii_2019 gii_diff                       geometry
## 1     0.753    0.665    0.088 MULTIPOLYGON (((61.27655 35...
## 2     0.246    0.156    0.090 MULTIPOLYGON (((19.57083 41...
## 3     0.519    0.437    0.082 MULTIPOLYGON (((4.603354 36...
## 4     0.551    0.537    0.014 MULTIPOLYGON (((23.47611 -1...
## 5     0.364    0.306    0.058 MULTIPOLYGON (((-71.85916 -...
## 6     0.346    0.239    0.107 MULTIPOLYGON (((46.54037 38...
## 7     0.136    0.080    0.056 MULTIPOLYGON (((151.5403 -2...
## 8     0.111    0.054    0.057 MULTIPOLYGON (((10.47124 46...
## 9     0.338    0.314    0.024 MULTIPOLYGON (((51.29271 38...
## 10    0.369    0.324    0.045 MULTIPOLYGON (((-78.205 25....

Plotting

plot filled map

fig <- plot_ly()
g <- list(
  fitbounds = "locations",
  visible = FALSE
)
fig <- fig %>% add_trace(
    type="choropleth",
    locations=world_gii$iso3,
    z=world_gii$gii_diff,
    colorscale="Viridis",
    text= ~paste('</br> Country: ', world_gii$country,
                '</br> GII 2010: ', world_gii$gii_2010,
                 '</br> GII 2019: ', world_gii$gii_2019),
    zmin=-0.5,
    zmax=0.5,
    marker=list(line=list(width=0))
  )
fig <- fig %>% colorbar(title = "GII Change,",y = 0.7)
fig <- fig %>% layout(
    title = list(text = 'Global Gender Inequality Index Change from 2010 to 2019<br>Source:<a href="https://hdr.undp.org/data-center/documentation-and-downloads">United Nations Development Programme</a>',y = 0.9), geo = g, margin=c(l=10, r=10, t=10, b=10)
)

fig